home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / Sample Editors⁄Viewers / SamplePart (C++) / Source / SamplePart.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-06  |  6.5 KB  |  215 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SamplePart.h
  3.  
  4.     Contains:    Sample part editor class implementation
  5.  
  6.     Written by:    Steve Smith
  7.     
  8.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  9. */
  10.  
  11. #ifndef _SAMPLEPART_
  12. #define _SAMPLEPART_
  13.  
  14. // -- Compiler/Preprocessor Switches --
  15.  
  16. #ifndef _COMPILERDEFS_
  17. #include "CompDefs.h"
  18. #endif
  19.  
  20. // -- OpenDoc Includes --
  21.  
  22. #ifndef _ODTYPES_
  23. #include <ODTypes.h>
  24. #endif
  25.  
  26. // -- Macintosh Includes --
  27.  
  28. #ifndef __TYPES__
  29. #include <Types.h>
  30. #endif
  31.  
  32. // -- Forward Declarations --
  33.  
  34. class Environment;
  35. class ODFacet;
  36. class ODFocusSet;
  37. class ODFrame;
  38. class ODMenuBar;
  39. class ODShape;
  40. class ODStorageUnit;
  41. class ODWindow;
  42. class CList;
  43.  
  44. struct WindowProperties;
  45.  
  46.  
  47. #pragma import on
  48.  
  49. class SamplePart {
  50.     
  51.       //==================================
  52.       // Overridden Public ODPart Methods
  53.       //==================================
  54.     public:
  55.     
  56.     SamplePart();
  57.     virtual ~SamplePart();
  58.     
  59.     // -- Initialization --
  60.     
  61.     void        InitPart(Environment* ev, ODStorageUnit* storageUnit,
  62.                                         ODPart* partWrapper);
  63.     void        InitPartFromStorage(Environment* ev, ODStorageUnit* storageUnit,
  64.                                         ODPart* partWrapper);
  65.     
  66.     // -- Storage --
  67.     
  68.     void        Release(Environment* ev);
  69.     void        ReleaseAll(Environment* ev);
  70.     ODSize        Purge(Environment* ev, ODSize size);
  71.     void        Externalize(Environment* ev);
  72.     void        ExternalizeKinds(Environment* ev, ODTypeList* kindset);
  73.     void        ChangeKind(Environment* ev, ODType kind);
  74.     void        CloneInto(Environment* ev, ODDraftKey key,
  75.                                         ODStorageUnit* destinationSU,
  76.                                         ODFrame* initiatingFrame);
  77.     void        WritePartInfo(Environment* ev, ODInfoType partInfo,
  78.                                         ODStorageUnitView* storageUnitView);
  79.     ODInfoType    ReadPartInfo(Environment* ev, ODFrame* frame,
  80.                                         ODStorageUnitView* storageUnitView);
  81.     void        ClonePartInfo(Environment *ev, ODDraftKey key, ODInfoType partInfo,
  82.                                         ODStorageUnitView* storageUnitView,
  83.                                         ODFrame* scopeFrame);
  84.     
  85.     // -- Layout --
  86.     
  87.     void        DisplayFrameAdded(Environment* ev, ODFrame* frame);
  88.     void        DisplayFrameRemoved(Environment* ev, ODFrame* frame);
  89.     void        DisplayFrameClosed(Environment* ev, ODFrame* frame);
  90.     void        DisplayFrameConnected(Environment* ev, ODFrame* frame);
  91.     void        AttachSourceFrame(Environment* ev, ODFrame* frame,
  92.                                         ODFrame* sourceFrame);
  93.     void        ViewTypeChanged(Environment* ev, ODFrame* frame);
  94.     void        FrameShapeChanged(Environment* ev, ODFrame* frame);
  95.     ODID        Open(Environment* ev, ODFrame* frame);
  96.         
  97.     // -- Imaging --
  98.     
  99.     void        Draw(Environment* ev, ODFacet* facet, ODShape* invalidShape);
  100.     void        GeometryChanged(Environment* ev, ODFacet* facet,
  101.                                         ODBoolean clipShapeChanged,
  102.                                         ODBoolean externalTransformChanged);
  103.     void        HighlightChanged(Environment* ev, ODFacet* facet);
  104.     void        FacetAdded(Environment* ev, ODFacet* facet);
  105.     void        FacetRemoved(Environment* ev, ODFacet* facet);
  106.     
  107.     // -- Activation --
  108.     
  109.     ODBoolean    BeginRelinquishFocus(Environment* ev, ODTypeToken focus,
  110.                                         ODFrame* ownerFrame,
  111.                                         ODFrame* proposedFrame);
  112.     void        CommitRelinquishFocus(Environment* ev, ODTypeToken focus,
  113.                                         ODFrame* ownerFrame,
  114.                                         ODFrame* proposedFrame);
  115.     void        AbortRelinquishFocus(Environment* ev, ODTypeToken focus,
  116.                                         ODFrame* ownerFrame,
  117.                                         ODFrame* proposedFrame);
  118.     void        FocusAcquired(Environment* ev,ODTypeToken focus,
  119.                                         ODFrame* ownerFrame);
  120.     void        FocusLost(Environment* ev,ODTypeToken focus,
  121.                                         ODFrame* ownerFrame);
  122.     
  123.     // -- Event Handling --
  124.     
  125.     ODBoolean    HandleEvent(Environment* ev, ODEventData* event,
  126.                                         ODFrame* frame, ODFacet* facet,
  127.                                         ODEventInfo* eventInfo);
  128.     void        AdjustMenus(Environment* ev, ODFrame* frame);
  129.     
  130.     
  131.       //===================================
  132.     // Newly Introduced Internal Methods
  133.       //===================================
  134.     protected:
  135.     
  136.     // -- Initialization --
  137.     
  138.     void        Initialize(Environment* ev);
  139.     
  140.     // -- Storage --
  141.     
  142.     void        CheckAndAddProperties(Environment* ev,
  143.                                         ODStorageUnit* storageUnit);
  144.     void        CleanseContentProperty(Environment* ev,
  145.                                         ODStorageUnit* storageUnit);
  146.     void        InternalizeStateInfo(Environment* ev,
  147.                                         ODStorageUnit* storageUnit);
  148.     void        InternalizeContent(Environment* ev,
  149.                                         ODStorageUnit* storageUnit);
  150.     void        ExternalizeStateInfo(Environment* ev,
  151.                                         ODStorageUnit* storageUnit,
  152.                                         ODDraftKey key, ODFrame* scopeFrame);
  153.     void        ExternalizeContent(Environment* ev, ODStorageUnit* storageUnit,
  154.                                         ODDraftKey key, ODFrame* scopeFrame);
  155.     void        SetDirty(Environment* ev);
  156.     
  157.     // -- Event Handling --
  158.     
  159.     ODBoolean    HandleMenuEvent(Environment* ev, ODEventData* event,
  160.                                            ODFrame* frame);
  161.     ODBoolean    HandleMouseEvent(Environment* ev, ODEventData* event,
  162.                                         ODFacet* facet, ODEventInfo* eventInfo);
  163.     void        DoMouseEvent(Environment* ev, ODFacet* facet, Point* where);
  164.     void        DoDialogBox(Environment* ev, ODFrame* frame,
  165.                                           ODSShort dialogID, ODUShort errorNumber = 0);
  166.     
  167.     // -- Imaging --
  168.     
  169.     void        DrawFrameView(Environment* ev, ODFacet* facet);
  170.     void        DrawIconView(Environment* ev, ODFacet* facet);
  171.     void        DrawThumbnailView(Environment* ev, ODFacet* facet);
  172.     PicHandle    GenerateThumbnail( Environment*    ev, ODFrame* frame);
  173.     
  174.     // -- Activation --
  175.     
  176.     void        PartActivated(Environment* ev, ODFrame* frame);
  177.     ODBoolean    ActivateFrame(Environment* ev, ODFrame* frame);
  178.     void        WindowActivating(Environment* ev, ODFrame* frame,
  179.                                         ODBoolean activating);
  180.     void        RelinquishAllFoci(Environment* ev, ODFrame* frame);
  181.     
  182.     // -- Layout --
  183.     
  184.     ODWindow*    AcquireFramesWindow(Environment* ev, ODFrame* frame);
  185.     ODWindow*    CreateWindow(Environment* ev, ODFrame* frame, ODType frameType,
  186.                                         WindowProperties* windowProperties);
  187.     void        CleanupWindow(Environment* ev, ODFrame* frame);
  188.     WindowProperties*    GetDefaultWindowProperties(Environment* ev, ODFrame* frame,
  189.                                         Rect* windowRect);
  190.     WindowProperties*    GetSavedWindowProperties(Environment* ev, ODFrame* frame);
  191.     Rect        CalcPartWindowSize(Environment* ev, ODFrame* sourceFrame);
  192.     Rect        CalcPartWindowPosition(Environment* ev, ODFrame* frame,
  193.                                         Rect* partWindowBounds);
  194.     ODFacet*    GetActiveFacetForFrame(Environment* ev, ODFrame* frame);
  195.     ODShape*    CalcNewUsedShape(Environment* ev, ODFrame* frame);
  196.     void        UpdateFrame(Environment* ev, ODFrame* frame, ODTypeToken view,
  197.                                         ODShape* usedShape);
  198.     void        CleanupDisplayFrame(Environment* ev, ODFrame* frame,
  199.                                         ODBoolean frameRemoved);
  200.     void        ZoomPartWindow(Environment* ev, ODFrame* frame, ODWindow* window,
  201.                                         ODBoolean openingWindow);
  202.                                         
  203.     
  204.       //========================
  205.     private:
  206.  
  207.     CList*        fDisplayFrames;
  208.     ODBoolean    fDirty;
  209.     ODPart*        fSelf;
  210.     ODBoolean    fReadOnlyStorage;
  211. };
  212.  
  213. #pragma import off
  214.  
  215. #endif